package com.bidepan.validation.three;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

//
// 基于方法实现数据校验
//
public class TestUser {
    @Test
    public void test(){
        ApplicationContext context = new AnnotationConfigApplicationContext(ValidationConfig.class);
        MyService myService = context.getBean(MyService.class);
        User user = new User();
        user.setName("张三");
        user.setAge(20);
        user.setPhone("13097262850");
        user.setMessage("helloworld");
        try{
            System.out.println(myService.testMethod(user));
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}
